#include "Classes.h"

Digit:: Digit(const int& i_value) throw (const std::string&)
{
	if(i_value<0 || i_value>9)
		throw std::string("Digit can not be not in [0,9]");
	mp_digit=i_value;	
};

Digit& Digit:: operator = (const char& i_char) throw (const std::string&)
{
	if(int(i_char)<48 || int(i_char)>57)
		throw std::string("Invalid format of the digit");
	mp_digit=int(i_char)-48;
	return *this;
};

Digit& Digit:: operator = (const int& i_int) throw (const std::string&)
{
	if(i_int<0 || i_int>9)
		throw std::string("Digit can not be not in [0,9]");
	mp_digit=i_int;
	return *this;
};

std::ostream& operator << (std::ostream& i_os, const Digit& i_digit)
{
	i_os.put(i_digit.mp_digit);
	return i_os;
};

